<template>
  <el-menu :default-active="defActive" mode="horizontal" background-color="#fff" text-color="rgb(96,98,102)"
    active-text-color="rgb(92, 168, 252);" class="dw-menu-height dw-menu" router>
    <el-menu-item index="/home/queryUser"
      v-if="super_admin_flag === 'true' || high_admin_flag === 'true'">用户管理</el-menu-item>
    <el-menu-item index="/home/profile"
      v-if="super_admin_flag === 'true' || high_admin_flag === 'true'">学生档案</el-menu-item>
    <el-menu-item index="/home/user">个人中心</el-menu-item>
    <el-menu-item index="/home/viewQuestionnaire" v-if="super_admin_flag === 'true'">查询问卷</el-menu-item>
    <el-menu-item index="/home/viewQuestionnaire_school" v-if="mid_admin_flag === 'true'">查询问卷</el-menu-item>
    <el-sub-menu index="2" v-if="high_admin_flag === 'true'">
      <template #title>查询问卷</template>
      <el-menu-item index="/home/viewQuestionnaire">地区</el-menu-item>
      <el-menu-item index="/home/viewQuestionnaire_school">学校</el-menu-item>

    </el-sub-menu>
    <!-- <el-menu-item index="/home/viewQuestionnaire" v-if="high_admin_flag === 'true'">查询问卷</el-menu-item> -->
    <el-menu-item index="/home/openQuestionnaireh"
      v-if="high_admin_flag === 'true' || super_admin_flag === 'true'">测评报告(个人)</el-menu-item>
    <el-menu-item index="/home/openQuestionnairem"
      v-if="mid_admin_flag === 'true' || super_admin_flag === 'true'">测评报告(学校)</el-menu-item>
  </el-menu>
</template>
<script>
import Cookies from 'js-Cookie'

export default {
  name: 'DwNavMenu',
  data() {
    return {
      defActive: '/home/queryUser',
      super_admin_flag: false,
      high_admin_flag: false,
      mid_admin_flag: false
    }
  },
  watch: {
    $route: function (to, from) {
      this.setDefActive()
    }
  },
  mounted() {
    this.setDefActive()
    this.super_admin_flag = Cookies.get("super_admin")
    this.high_admin_flag = Cookies.get("high_admin")
    this.mid_admin_flag = Cookies.get("mid_admin")
  },
  methods: {

    setDefActive() {
      const fullPath = this.$route.fullPath
      if (fullPath.indexOf('/home/queryUser') >= 0) {
        this.defActive = '/home/queryUser'
      } else if (fullPath.indexOf("/home/profile") >= 0) {
        this.defActive = "/home/profile";
      }
      else if (fullPath.indexOf('/home/user') >= 0) {
        this.defActive = '/home/user'
      }
      else if (fullPath.indexOf('/home/viewQuestionnaire') >= 0) {

        this.defActive = '/home/viewQuestionnaire'

      }
      else if (fullPath.indexOf('/home/openQuestionnaires') >= 0) {
        this.defActive = '/home/openQuestionnaires'
      }
      else if (fullPath.indexOf('/home/openQuestionnaireh') >= 0) {
        this.defActive = '/home/openQuestionnaireh'
      }
      else if (fullPath.indexOf('/home/openQuestionnairem') >= 0) {
        this.defActive = '/home/openQuestionnairem'
      }
    }
  }
}
</script>
  
<style scoped>
.dw-menu-height,
.dw-menu-height>.el-menu-item,
.dw-menu-height>.el-submenu /deep/ .el-submenu__title {
  height: 80px;
  line-height: 80px;
  font-weight: 400;
  /* font-size: 16px; */
}

.dw-menu {
  border-bottom: none;
}
</style>
  